<?php

namespace App\Admin\Controllers\Statistics;

use App\Models\Statistics\Trade;
use App\Models\User\User;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use Encore\Admin\Widgets;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\Box;
use Encore\Admin\Widgets\Callout;

class RegisterController extends Controller
{

    public $header = '新增注册量统计';

    /**
     * Index interface.
     *
     * @return Content
     */
    public function index(Request $request)
    {
        return Admin::content(function (Content $content) use ($request) {

            $content->header($this->header);
            $content->description('description');

            $type       = $request->get('type',1);
            $start_time = $request->get('start_time');
            $end_time   = $request->get('end_time');

            $content->row(view('admin.statistics.register'));
        });
    }


    public function getUserRegister(Request $request)
    {
        $date_type  = $request->get('date_type',0);
        $role_type  = $request->get('role_type', 0);
        $month = $request->get('month');
        $year  = $request->get('year');

        $model = new User();

        if ($date_type == 0){
            $data = $model->statisticsRegisterByMonth($role_type, $month);
        } else {
            $data = $model->statisticsRegisterByYear($role_type, $year);
        }

        return response()->json(compact('data'));
    }


}
